using UnityEngine;

namespace LS.SimpleInput
{
    [System.Serializable]
    public class UserInputSetting
    {
        internal static readonly UserInputSetting defaultSetting = new UserInputSetting();

        [Tooltip("若激活，则不会在EventSystem检测到的物体上响应手势事件，EventSystem会检测所有挂载Raycaster组件的物体，一般情况下基本都是Unity GUI。")]
        public bool eventSystemCompatibility = true;

        [Tooltip("Stationary状态的误差容量，移动距离超过该值则判定状态为Move。")]
        public float stationaryTolerance = 15f;

        [Space(20)]
        [Tooltip("LongTap的检测优先级，会影响Tap和LongTap的检测顺序。")]
        public LongTapPriority longTapPriority = LongTapPriority.LongTap;

        [Tooltip("LongTap的判定时间，触发时间超过该值则判定为LongTap。")]
        public float longTapTime = 0.5f;

        [Space(20)]
        [Tooltip("双击检测开关。")]
        public bool enableDoubleTap = true;

        [Tooltip("DoubleTap的判定时间，两次Tap的触发间隔低于该值则触发DoubleTap。")]
        public float doubleTapTime = 0.35f;

        [Space(20)]
        [Range(0,1)]
        [Tooltip("方向判定容差,该值会参与方向dot值的计算。")]
        public float movementDirectionTolerance = 0.85f;

        public void Copy(UserInputSetting inputSetting)
        {
            this.stationaryTolerance = inputSetting.stationaryTolerance;
            this.longTapTime = inputSetting.longTapTime;
            this.doubleTapTime = inputSetting.doubleTapTime;
        }

        public UserInputSetting Clone()
        {
            return Clone(this);
        }

        public static UserInputSetting Clone(UserInputSetting source)
        {
            UserInputSetting newSetting = new UserInputSetting();
            newSetting.Copy(source);
            return newSetting;
        }
    }
    
}
